package org.ccay.manage.enumerable.vo;

import java.io.Serializable;

import org.ccay.enumerable.EnumItem;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

/**
 * 枚举类型展示对象
 * @author chaowangbang
 *
 */
@JsonIgnoreProperties(ignoreUnknown=true)
public class EnumItemVO implements Serializable{

	private static final long serialVersionUID = 1L;
	/**
	 * type+"|"+value拼接的虚拟id
	 */
	private String virtualId;
	
	/** 枚举类型 */
	private String type;
	/** 枚举代码 */
	private String name;
	/** 枚举值 */
	private String value;
	/** 枚举显示值 */
	private String displayValue;
	/** 枚举索引 */
	private int index;
	/** 枚举值来源 */
	private String source;
	/** 描述 */
	private String description;
	
	//无参数构造函数
	public EnumItemVO(){}
	
	public EnumItemVO(EnumItem item,String description) {
		this.type = item.getType();
		this.name = item.getName();
		this.value = item.getValue();
		this.displayValue = item.getDisplayValue();
		this.index = item.getIndex();
		this.source = item.getSource();
		this.description = description;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof EnumItemVO || obj instanceof EnumItem))
			return false;
		if(obj instanceof EnumItemVO){
			EnumItemVO other = (EnumItemVO) obj;
			if (type == null) {
				if (other.type != null)
					return false;
			} else if (!type.equals(other.type))
				return false;
			if (value == null) {
				if (other.value != null)
					return false;
			} else if (!value.equals(other.value))
				return false;
		}
		if(obj instanceof EnumItem){
			EnumItem other = (EnumItem) obj;
			if (type == null) {
				if (other.getType() != null)
					return false;
			} else if (!type.equals(other.getType()))
				return false;
			if (value == null) {
				if (other.getValue() != null)
					return false;
			} else if (!value.equals(other.getValue()))
				return false;
		}
		return true;
	}

	public String getVirtualId() {
		return virtualId;
	}

	public void setVirtualId(String virtualId) {
		this.virtualId = virtualId;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getDisplayValue() {
		return displayValue;
	}

	public void setDisplayValue(String displayValue) {
		this.displayValue = displayValue;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
}
